package com.itheima.service.impl.service;


import com.aliyuncs.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.common.R;
import com.itheima.dao.CategoryDao;
import com.itheima.domain.Category;
import com.itheima.domain.Employee;
import com.itheima.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> implements CategoryService {
     @Autowired
     private  CategoryDao categoryDao;
    public Page pageSelect(int page , int pageSize , String name){
        //构造一个page类 ,同时开启拦截器.
        Page<Category> page1 = new Page<>(page, pageSize);
        LambdaQueryWrapper<Category> lqw = new LambdaQueryWrapper<>();
        lqw.like(!StringUtils.isEmpty(name), Category::getName, name)
                .orderByDesc(Category::getUpdateTime);

        categoryDao.selectPage(page1,lqw);

        return page1;
    }
//    public List<R<Category>> catagroyPulldown(){
//        categoryDao.
//    }

}
